<?php


namespace app\api\controller;

use app\common\lib\Arr;
use app\common\lib\Show;

class Category extends ApiBase
{
    public function index()
    {
        //获取所有分类数据
        $cate_list = (new \app\admin\business\Category())->getNormalCategories();
        $res = Arr::getTree($cate_list);
        return show(1, 'ok', $res);
    }

    public function search($cid)
    {
        $data = (new \app\admin\business\Category())->getData(intval($cid));

        return Show::success($data);
    }

    public function sub($cid)
    {
        $data = (new \app\admin\business\Category())->getSubData(intval($cid));

        return Show::success($data);
    }
}